package cn.wolfcode.web.controller;

import cn.wolfcode.domain.Systemdictionary;
import cn.wolfcode.quest.JsonResult;
import cn.wolfcode.quest.QueryObject;
import cn.wolfcode.service.ISystemDictionaryService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

//字典目录表
@Controller
@RequestMapping("/systemDictionary")
public class SystemDictionaryController {
     @Autowired
     private ISystemDictionaryService systemDictionaryService;



    @RequestMapping("/list")
    public String systemDictionaryList(Model model,@ModelAttribute("qo") QueryObject qo){

        PageInfo list=systemDictionaryService.selectList(qo);

        model.addAttribute("pageResult",list);

        return "/systemDictionary/list";
    }


     @RequestMapping("/saveOrUpdate")
     @ResponseBody
     public JsonResult saveOrUpdate(Systemdictionary systemdictionary){
         if(systemdictionary.getId()!=null){
             systemDictionaryService.updateByPrimaryKey(systemdictionary);
         }else {
             systemDictionaryService.insert(systemdictionary);
         }

        return new JsonResult();
     }


     @RequestMapping("/delete")
    @ResponseBody
    public JsonResult delete(Long id){
         systemDictionaryService.deleteByPrimaryKey(id);
        return new JsonResult();
     }
}
